package com.itheima.udpguang;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/*
udp 发送端
 */
public class SendClient {

    public static void main(String[] args) throws IOException {
        //创建对象
        DatagramSocket ds = new DatagramSocket();

        String s="嘿嘿嘿,明天就把你抬走";
        InetAddress ip = InetAddress.getByName("255.255.255.255");
        //组织数据
        DatagramPacket dp = new DatagramPacket(s.getBytes(),s.getBytes().length,ip,8888);

        //调用方法
        ds.send(dp);

        //释放资源
        ds.close();


    }
}
